﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteRequireLogin.Master" AutoEventWireup="true" CodeBehind="Check_Revenue.aspx.cs" Inherits="TranTekBE.Check_Revenue.Check_Revenue" %>

<%@ Register Src="~/Admin/UserControl/MenuAdmin.ascx" TagPrefix="uc1" TagName="MenuAdmin" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

  <script type="text/javascript" src="https://www.google.com/jsapi"></script>

    </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">
     <asp:UpdatePanel ID="UpdatePanel" runat="server"  >
        <ContentTemplate>
            <div style="position: absolute;margin-top: 50px;">

                <uc1:MenuAdmin runat="server" id="MenuAdmin" />


            <h1 style="">DOANH SỐ BÁN HÀNG THEO NGÀY</h1>
            
            <table style="width:400px">
                <tr><td>
                    <br></td></tr>
                <tr>
                    <td class="tdLeftM msgError"><asp:Literal ID="ltError" runat="server" /></td>
                    <td></td>
                </tr>


                <tr>
                    <td colspan="4">
                        <table>
                                <tr>
                                    <td>
                                        Xem trong khoản :
                                        <asp:DropDownList runat="server" ID="ddlLoaiXem" AutoPostBack="true" OnSelectedIndexChanged="ddlLoaiXem_SelectedIndexChanged">
                                            <asp:ListItem  Text="Chọn thời gian" Value=""></asp:ListItem>
                                            <asp:ListItem Selected="True" Text="Ngày hôm nay" Value="today"></asp:ListItem>
                                            <asp:ListItem  Text="Ngày hôm qua" Value="lastDay"></asp:ListItem>
                                            <asp:ListItem  Text="Tuần này" Value="nowWeek"></asp:ListItem>
                                            <asp:ListItem  Text="Tuần trước" Value="lastWeek"></asp:ListItem>
                                            <asp:ListItem  Text="Tháng này" Value="nowMonth"></asp:ListItem>
                                            <asp:ListItem  Text="Tháng trước" Value="lastMonth"></asp:ListItem>
                                            <asp:ListItem  Text="Năm nay" Value="nowYear"></asp:ListItem>
                                            <asp:ListItem  Text="Năm trước" Value="lastYear"></asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td>
                                        Cửa hàng :
                                        <asp:DropDownList runat="server" ID="ddlStore" OnSelectedIndexChanged="ddlStore_SelectedIndexChanged" AutoPostBack="true">
                                            <asp:ListItem Selected="True" Text="Chọn hết" Value=""></asp:ListItem>
                                        </asp:DropDownList>

                                    </td>
                                    <td rowspan="6">
                                        <asp:Button ID="btnFilter" runat="server" CssClass="buttonPharmacity" Height="55px" OnClick="btnFilter_Click" Text="Lọc" Width="151px" /> 
                                             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                             
                                         
                                    </td>
                                </tr>
                                <tr>
                                    <td>Từ ngày :<asp:TextBox runat="server" ID="txtFrom" Width="90px" Enabled="false"></asp:TextBox></td>
                                    
                                    <td>Đến ngày:<asp:TextBox runat="server" ID="txtTo" Width="90px" Enabled="false"></asp:TextBox></td>
                                </tr>
                        </table>
                    </td>
                    <td></td>
                </tr>
                 
               
                <tr ><td style="padding-bottom:20px;padding-top:20px" colspan="4"><hr /></td></tr>
                <tr>
                    <td class="tdLeftM">
                        <asp:PlaceHolder ID="phPageNavigation" runat="server" Visible="false">
                        <asp:Button ID="btnSort" runat="server" Text="Sắp sếp" Width="70px" CommandName="Sort" oncommand="ControlClick_Command" />
                        <asp:DropDownList ID="ddlSortBy" runat="server" OnSelectedIndexChanged="ddlSortBy_SelectedIndexChanged">
                            <asp:ListItem Text="Cửa Hàng" Value="Stores"  />
                            <asp:ListItem Selected="True" Text="Doanh Số" Value="TotalRevenue"  />
                        </asp:DropDownList>
                        <asp:DropDownList ID="ddlSortDirect" runat="server" OnSelectedIndexChanged="ddlSortDirect_SelectedIndexChanged">
                            <asp:ListItem Text="Tăng dần" Value="ASC"  />
                            <asp:ListItem Selected="True" Text="Giảm dần" Value="DESC" />
                        </asp:DropDownList>
                        
                            <asp:Button ID="btnGoPage" runat="server" Text="Đến trang" CommandName="GoToPage" oncommand="ControlClick_Command" />
                            <asp:TextBox ID="txtGoPage" runat="server" Width="30px" MaxLength="3" />
                            <asp:Button ID="btnPrev" runat="server" CommandName="GoToPrev" Text="<<" oncommand="ControlClick_Command" />
                            <asp:Literal ID="ltPage" runat="server" />
                            <asp:Button ID="btnNext" runat="server" CommandName="GoToNext" Text=">>" oncommand="ControlClick_Command" />
                       
                        Dòng trên trang: <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" onselectedindexchanged="ddlPageSize_SelectedIndexChanged" />
                             </asp:PlaceHolder>
                    </td>
                    <td colspan="4"></td>
                </tr>
                <tr>
                    <td class="tdLeftT">
                        <div style="width:132px;margin-top: -30px;">
                            <table width="100%" class="tblGrid">
                                <caption>
                                    Dữ liệu
                                    <asp:Literal ID="ltlDuLieuTu" runat="server"></asp:Literal>
                                </caption>
                            </table>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th class="thGrid" style="width:10px">STT.</th>
                    <th class="thGrid" style="width: 90px;">
                        <asp:LinkButton ID="lbCuaHangSort" runat="server" CommandArgument="ASC" CommandName="Stores" CssClass="GridHeader" onclick="Sort_Click" Text="Cửa Hàng" />
                    </th>
                    <th class="thGrid" style="width: 90px;">
                        <asp:LinkButton ID="lbDoanhThu" runat="server" CommandArgument="Desc" CommandName="TotalRevenue" CssClass="GridHeader sortDesc" onclick="Sort_Click" Text="Doanh Thu" />
                    </th>
                    <th class="thGrid" style="width: 90px;">Tổng số lần giao dịch</th>
                </tr>
                <tr>
                    <td class="tdGrid tdCenterM" style="height: 35px">
                        <table class="centerObject">
                            <tr>
                                <td>
                                    <asp:ImageButton ID="btnClearSearch" runat="server" Height="10px" ImageUrl="../images/ico_clear_search.gif" onclick="btnClearSearch_Click" ToolTip="Clear Search" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="btnSearch" runat="server" ImageUrl="../images/ico_search.gif" onclick="btnSearch_Click" ToolTip="Search" />
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td class="tdGrid tdCenterM" style="height: 35px">
                        <asp:TextBox ID="txtStoreName" runat="server" Width="90%" />
                    </td>
                    <td class="tdGrid tdCenterM" style="height: 35px"></td>
                    <td class="tdGrid tdCenterM" style="height: 35px"></td>
                </tr>
                <asp:Repeater ID="rpRevenue" runat="server">
                    <ItemTemplate>
                        <tr style='<%# ThuVien.FunctionsUtils.CSS_RowInTable(Container.ItemIndex,"#FFFFE0","#D7E3F2") %>'>
                            <td class="tdGrid tdCenterM"><%# Container.ItemIndex + 1 %></td>
                            <td class="tdGrid tdLeftM">
                                <div style="float: left">
                                    <%# ThuVien.FunctionsUtils.HTMLEncode(Eval("Stores"))%>
                                </div>
                                <div style="float: right; text-align: right;">
                                </div>
                            </td>
                            <td class="tdGrid tdCenterM"><%# GetRevenus(Eval("TotalRevenue"))%></td>
                            <td class="tdGrid tdCenterM"><%# GetNumOfTransaction(Eval("Stores"))%></td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                <tr>
                    <td align="right" colspan="2"><b>Tổng Cộng:</b></td>
                    <td class="tdCenterM">
                        <asp:Literal ID="ltlTongCong" runat="server"></asp:Literal>
                    </td>
                    <td align="center">
                        <asp:Literal ID="ltlTongCongSoGiaoDich" runat="server"></asp:Literal>
                    </td>
                </tr>
                <asp:Literal ID="ltNoRecord" runat="server" Visible="false">
                                <tr><td colspan="8" class="tdGrid tdCenterM">Không có dữ liệu</td></tr>
                            </asp:Literal>
            </table>
                </td>
                <td>
                    
                </td>
                </tr>
                </table>
             <div style="float:right;width:600px;margin-top: -440px;height:500px" id="linechart"></div>
                <br />
                <br />
                <br />
                <br />
                <br />
                <br />
            <script type="text/javascript">
                function LoadJS() {
                  
                    $("#<%=txtFrom.ClientID %>").datepicker(
                        {
                            changeMonth: true,
                            changeYear: true,
                            showButtonPanel: true,
                        }
                    );
                    $("#<%=txtTo.ClientID %>").datepicker(
                         {
                             changeMonth: true,
                             changeYear: true,
                             showButtonPanel: true,
                         }
                        );


                    //setTimeout("DrawChart();",5000);
                    DrawChart11();
                
                }

                function DrawChart11()
                {
                    
                    google.load("visualization", "1", { packages: ["corechart"] });
                    
                    google.setOnLoadCallback(drawChart);
                    
                    function drawChart() {
                        var json = <%= ViewState["DatasChart"] %>;// Get biến từ Server qua Client
                        var arr = [ ["Tháng", "Tuần trước","Tuần này"] ];
                        json.res.forEach(function(item) { 
                            arr.push( [ item.Thu,item.ThisWeek, item.LastWeek] );// push array
                        });
                        var data = google.visualization.arrayToDataTable(arr);
                        var options = {
                            title: 'Biểu đồ tiêu doanh thu',//Name chart
                            hAxis: { title: 'Biểu đồ doanh thu tuần', titleTextStyle: { color: 'red' } }
                        };

                        var chart = new google.visualization.LineChart(document.getElementById('linechart'));//Paint chart
                        chart.draw(data, options);
                    
                    }

                    
                }

               

               
                
                
           
            </script>
        </div>
           
        </ContentTemplate>
    </asp:UpdatePanel>

    
</asp:Content>
